/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.fyx.cms.web;

import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ManagedBean;
import org.fyx.cms.ejb.CmsLocal;
import org.fyx.cms.entity.CmsArticle;
import org.fyx.linker.web.LinkerLocal;

/**
 *
 * @author ydenek
 */
@ManagedBean
@SessionScoped
public class CmsArticleList {

    @EJB
    CmsLocal cms;
    @EJB
    LinkerLocal linker;
    private CmsArticle selectedArticle;

    /** Creates a new instance of CmsArticleList */
    public CmsArticleList() {
    }

    public CmsLocal getCms() {
        return cms;
    }

    public void setCms(CmsLocal cms) {
        this.cms = cms;
    }

    public CmsArticle getSelectedArticle() {
        return selectedArticle;
    }

    public int getIdSelectedArticle() {
        return selectedArticle.getId();
    }

    public void setSelectedArticle(CmsArticle selectedArticle) {
        this.selectedArticle = selectedArticle;
    }

    public void deleteSelectedArticle() {
        cms.deleteArticle(selectedArticle);
        linker.removeMenuItem("cms_article_" + Integer.toString(selectedArticle.getId()));
    }
}
